package com.bgds.sys.api.project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bgds.sys.api.project.service.DictService;
import com.bgds.sys.module.entity.project.DictItem;
import com.bgds.sys.module.mapper.DictItemMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author chenchao
 * @date 2021/9/14
 */
@Service
public class DictServiceImpl implements DictService {

    @Resource
    private DictItemMapper dictItemMapper;

    @Override
    public List<DictItem> dictItemList(String code) {
        return dictItemMapper.selectList(new QueryWrapper<DictItem>().lambda().eq(DictItem::getCode, code).eq(DictItem::getIsDel, 0));
    }

    @Override
    public void deleteDictItem(String id) {
        DictItem item = new DictItem();
        item.setId(id);
        item.setIsDel(1);
        saveDictItem(item);
    }

    @Override
    public void saveDictItem(DictItem dictItem) {
        dictItemMapper.updateById(dictItem);
    }

    @Override
    public void addDictItem(DictItem dictItem) {
        dictItemMapper.insert(dictItem);
    }
}
